<!--用户列表页-->
<template>
    <div style="height: 100%;">
        <m-page-list
                :option="option"
                :page="page"
                :total="total"
                :table-data="tableData"
                :table-loading="tableLoading"
                v-model:value="query"
                @h-btn-click="hBtnClick"
                @col-btn-click="colBtnClick"
                @search-data="searchData"
        />
        <m-dialog-form ref="dialogRef" :data="dialogData" v-model:show="dialogShow" :option="dialogOption" @confirm="dialogConfirm" ></m-dialog-form>
    </div>
</template>

<script setup>

  import {ref,reactive,onMounted,nextTick} from 'vue'
  import {useRouter} from 'vue-router'
  //组件
  import MPageList from '@/components/PageList'
  import MDialogForm from '@/components/DialogForm/DialogForm'
  //请求
  import {getCustomer, addUser,editCustomer,delUser, getRole,getEmployeeInf} from '@/request/api/basicData'

  import {usePageList} from "../../composables/pageList";

  const router = useRouter();
  let opts = {
    auth_id: 'customer',
    getApi: getCustomer,addApi:addUser,editApi:editCustomer,delApi:delUser,
    idKey: 'customer_id'
  };
  let {option,page,total,tableLoading,tableData,query,dialogRef,dialogShow,dialogData,dialogOption,
    hBtnClick,colBtnClick,searchData,getDataList,dialogConfirm} = usePageList(opts);

  option.conditions = [
    {label: '手机号码',type: 'number',field_id: 'phone'},
    {label: '客户名称',type: 'text',field_id: 'customer_name'},
    {label: '客户编号',type: 'text',field_id: 'customer_id'},
  ];
  option.hLBtns = [];
  option.colBtns = [{title: '查看乘车人',id: 'check',type: 'primary',event: checkPassenger }];
  option.cols = [
    {prop: 'customer_id', label: '客户编号',},
    {prop: 'customer_name', label: '客户名称',},
    {prop: 'phone',label: '手机号码' },
    {prop: 'input_id',label: '录入员号' },
    {prop: 'input_name',label: '录入员名' },
    {prop: 'input_time',label: '录入时间' },
    {prop: 'modify_id',label: '修改员号' },
    {prop: 'modify_name',label: '修改员名' },
    {prop: 'modify_time',label: '修改时间' },
  ];
  option.titleList = [
    {name: '客户',path: '/customer'},
    {name: '乘车人',path: '/passenger'}
  ]
  dialogOption.fieldList = [
    {field_id: 'customer_id',label: '客户编号',type: 'text',col: 3 ,required: true,editDisabled: true },
    {field_id: 'customer_name',label: '客户名称',type: 'text',col: 3 ,},
    {field_id: 'phone',label: '手机号码',type: 'text',col: 3 ,},
  ];

  function checkPassenger(scope) {
    router.push({
      path:'/passenger',query: {customer_id: scope.row.customer_id}
    })
  }



</script>

<style scoped>

</style>
